<{include file="top.html" }>
<link rel="stylesheet" type="text/css" href="Public/Wap/css/LArea.css">
</head>
<body>
<header><a class="left_link" href="javascript:void(0);"></a>个人信息</header>
    <div class="xy-panel-content" style="bottom:0; padding:1rem 0;">
        <div class="xy-row vDirectionRow">
            <form action="<{U('User/update')}>" method="post" class="ui-form" id="uinfo_update">
                <div class="tx_ui-list">
                    <dl style="min-height: 2rem;text-align: right; padding:1rem;">
                        <i style="display:inline-block; float:left; line-height:5.5rem; color:#333;">头像</i>
                        <img src="<{$userinfo.uid|headpic}>" id="userhead" name="userhead" style="width:5.5rem; height:5.5rem; border-radius:50%;vertical-align:middle;" required>

                    </dl>
                </div>
                <ul class="con_ui-list">
                    <li class="ui-list">
                        <i>真实姓名</i>
                        <span><input type="text" value="<{$userinfo.realName}>" id="realName" name="realName" required/></span>
                    </li>
                    <li class="ui-list">
                        <i>昵称</i>
                        <span><input type="text" value="<{$userinfo.nickname}>" id="nickname" name="nickname" required /></span>
                    </li>
                    <li class="ui-list">
                        <a href="<{u('bind')}>">
                        <i>手机号码</i>
                        <span><input type="text" value="<{$userinfo.bindPhone|default:'未绑定'}>" id="phone"  readonly/></span>
                        </a>
                    </li>
                    <li class="ui-list">
                        <i>性别</i>
                        <span><select class="sex" required id="sex">
                            <option value="1" name="sex" selected>男</option>
                            <option value="2" name="sex" <{if $userinfo.sex == 2}>selected<{/if}>>女</option>
                        </select></span>
                    </li>
                    <li class="ui-list">
                        <i>生日</i>
                        <span><input type="date" value="<{$userinfo.birthday}>" id="birthday" name="birthday" required/></span>
                    </li>
                    <li class="ui-list">
                        <i>地区</i>
                        <span><input id="selectAddress" type="text" style="width:20.2rem;" readonly placeholder="省/市/区" value="<{if $userinfo.address != '....'}><{$address[0]}>,<{$address[1]}>,<{$address[2]}><{else}>省/市/区<{/if}>"/></span>
                        <input id="address" type="hidden" value="<{$userinfo.province}>,<{$userinfo.city}>,<{$userinfo.district}>" />
                    </li>
                </ul>
                <ul class="AdBox">
                    <li style="color:#333; height:3.3rem; line-height:3.3rem; background:none;">收货地址</li>
                    <li><textarea placeholder="" id="fullAddress"><{if $userinfo.address != '....'}><{$address[4]}><{/if}></textarea></li>
                </ul>
                <div class="integral_btn-group" style="padding:1rem;">
                    <a style=" display:block; width:100%; text-align:center; height:4rem; background:#37cbbb; color:#FFF; line-height:4rem; border-radius:.5rem; font-size:1.8rem; border:none;" id="btn" class="" href="javascript:void(0);">保存修改</a>
                    <!--<input type="submit" id="btn" class="fbpl_button" />-->
                </div>
                <{if $isInfoPerfect}>
                    <dl class="NumericalReminded"><a href="<{U('User/bind')}>">绑定手机得积分</a></dl>
                <{/if}>
            </form>
        </div>
    </div>


<!--弹出框 成功提示-->
<div id="applySuccess" class="hint-box" style="display:none;">
    <div class="hint nofollow_box">
        <div class="topic title">提示</div>
        <div class="list"></div>
        <button type="button" class="button zdl">知道了</button>
    </div>
</div>

<{include file="signBody.html"}>

</body>
</html>
<script src="<{$preStaticUrl}>Wap/js/flexible.js"></script>
<script src="<{$preStaticUrl}>Wap/js/LAreaData.js"></script>
<script src="<{$preStaticUrl}>Wap/js/LArea.min.js"></script>
<script>
    var area2 = new LArea();
    var district = $("#address").val().split(',')[2];
    var prov_sort = parseInt("<{$sort[0]}>"-1);
    var city_sort = parseInt("<{$sort[1]}>"-1);
    var dist_sort = parseInt("<{$sort[2]}>"-1);

    area2.init({
        'trigger': '#selectAddress',
        'valueTo': '#address',
        'keys': {
            id: 'value',
            name: 'text'
        },
        'type': 2,
        'data': [prov_data, city_data, dist_data],
        'finishF':function () {},

    });
    if(prov_sort>=0){
        if(city_sort < 0) city_sort = 0;
        if(dist_sort < 0) dist_sort = 0;
        area2.value=[prov_sort,city_sort,dist_sort];
    }


    var itemUrl= "<{U('User/index')}>";
    var flag = 0;
    $(function(){
        $('#btn').click(function(){
            var userhead = $('#userhead').val(),
                    realName    = $('#realName').val(),
                    nickname    = $('#nickname').val(),
                    sex         = $('#sex').val(),
                    birthday    = $('#birthday').val(),
                    address     = $('#address').val(),
                    action      = $('#uinfo_update').attr('action'),
                    detailAddress = $('#fullAddress').val();

            var param = {userhead:userhead,realName:realName,nickname:nickname,sex:sex,birthday:birthday,address:address,detailAddress:detailAddress};

            $.getJSON(action,param, function(data){
                if(data.status!=0){
                    layer.msg(data.msg);
//                    $("#applySuccess .list").html(data.msg);
//                    $("#applySuccess").show();
                }else{
                    flag = 1;
                    if(data.firstInfoPerfected){
                        layer.msg("信息完善成功，积分+100",{shift:5,offset:$(window).height() * 0.8});
                    } else{
                        layer.msg("修改成功");
                    }
                    window.history.go(-1);
                }
            });
            return false;
        });

        $(".button.zdl").click(function() {
            $(".hint-box").css({"display":"none"});
            if(flag == 1){
                window.history.go(-1);
                return false;
            }

        });

    });


</script>